<?php
    session_start();
    function create_image()
    {
        $md5_hash = md5(rand(0,999));
        $security_code = substr($md5_hash, 15, 5);
        $_SESSION["security_code"] = $security_code;
        // width & height
        $width = 125;
        $height = 30;
        // tạo hình cho capcha
        $image = ImageCreate($width, $height);
        $background = ImageColorAllocate($image, 255, 255, 255); // hình nền
        $font_color = ImageColorAllocate($image, 169, 189, 197); // màu chữ
        $font = '../../assets/font/UTM-Avo.ttf';
        // var_dump($font); exit();
        //
        // ImageFill($image, 0, 0, $background);
        imagettftext($image, 20, 0, 5, 25, $font_color, $font, $security_code);
        //
        header("Content-Type: image/jpeg");
        ImageJpeg($image);
        ImageDestroy($image);
    }
    create_image();
    exit();

?>